<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //石头下沉
        var arr02=[2,10,6,8,5];
        sign=false;
            var count=0;
            var i=0;
       while(i<arr02.length-1){
        i++;
            sign=false;
            var j=0
            while(j<arr02.length-i){
                
                j++;
                if(arr02[j]>arr02[j+1]){
                    temp=arr02[j];
                    arr02[j]=arr02[j+1];
                    arr02[j+1]=temp;
                    sign=true;
                }
                count++;
           }
            if(!sign)
          break;
        }
        console.log(arr02);
    </script>
</body>
</html>